package com.minyifang.wcspf.work.ui.goods.presenter;

import com.minyifang.wcspf.common.base.BasePresenter;
import com.minyifang.wcspf.common.config.network.Constants;
import com.minyifang.wcspf.common.config.network.RetrofitHelper;
import com.minyifang.wcspf.work.ui.goods.view.GoodsCommentView;
import com.minyifang.wcspf.work.ui.goods.view.GoodsDetailsView;

import org.json.JSONObject;

import java.util.HashMap;
import java.util.Map;

import okhttp3.MediaType;
import okhttp3.RequestBody;

public class GoodsCommentPresenter extends BasePresenter<GoodsCommentView> {
    /**
     * 获取商品评论头信息
     */
    public void getCommentHeadInfo(String goodsId) {
        Map<String, Object> data = new HashMap<>();
        data.put("comId", goodsId);
        final JSONObject jsonData = Constants.getJsonData(data, null);
        RequestBody requestBody = RequestBody.create(MediaType.parse("application/json"), jsonData.toString());
        addTask(RetrofitHelper.getInstance().getService().getCommentHeadInfo(requestBody), commentDescHttpRespond -> {
            if (commentDescHttpRespond.result == 1) {
                getView().onGetCommentHeadInfoSucceed(commentDescHttpRespond.data);
            }
        });
    }
}
